package cn.iocoder.yudao.module.blog.convert.user;

import cn.iocoder.yudao.module.blog.controller.app.user.vo.AppUserInfoRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface UserConvert {
    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    default AppUserInfoRespVO convert(MemberUserDO memberUserDO, MemberLevelDO memberLevelDO){
        AppUserInfoRespVO appUserInfoRespVO = new AppUserInfoRespVO();

        appUserInfoRespVO.setId(memberUserDO.getId());
        appUserInfoRespVO.setExperience( memberUserDO.getExperience() );
        appUserInfoRespVO.setNickname( memberUserDO.getNickname() );
        appUserInfoRespVO.setAvatar( memberUserDO.getAvatar() );
        appUserInfoRespVO.setMobile( memberUserDO.getMobile() );
        appUserInfoRespVO.setPoint( memberUserDO.getPoint() );
        if(memberLevelDO != null){
            appUserInfoRespVO.setLevel(memberLevelDO.getLevel());
        }else{
            appUserInfoRespVO.setLevel(0);
        }


        return appUserInfoRespVO;
    }
}
